﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SendSms.aspx.cs" Inherits="UI_SendSms" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
   <title>酒店好帮手-短 信 发 送 历 史 查 看 管 理</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="/images/style.css" rel="Stylesheet" />
    <script language="javascript" type="text/javascript" src="/js/jiazai.js"></script>
    <script src="/js/introbox.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
    <script language="javascript" type="text/javascript" src="/js/jquery-easyui/jquery.easyui.min.js"></script>
    <script language="javascript" type="text/javascript" src="/js/My97DatePicker/WdatePicker.js"></script>
    <script language="javascript" type="text/javascript" src="/js/pagefunction.js"></script>
    <script language="javascript" type="text/javascript">
        $(function () {
            var $tex = $("#txbContent");

            var ie = jQuery.support.htmlSerialize;
            var str = 0;
            var abcnum = 0;
            var maxNum = 140;
            var texts = 0;
            var num = 0;
            var sets = null;
            $tex.val("");
            //顶部的提示文字  
            $tex.focus(function () {
                if ($tex.val() == "") {
                    $("#info").html("您还可以输入的字数<span>70</span>");
                }
            })
            //            $tex.blur(function () {
            //                if ($tex.val() == "") {
            //                    $("#info").html("请在下面输入您的文字：");
            //                }
            //            })
            //文本框字数计算和提示改变  
            if (ie) {
                $tex[0].oninput = changeNum;
            } else {
                $tex[0].onpropertychange = changeNum;
            }
            function changeNum() {
                //汉字的个数  
                str = ($tex.val().replace(/\w/g, "")).length;
                //非汉字的个数  
                abcnum = $tex.val().length - str;
                total = str * 2 + abcnum;
                if (str * 2 + abcnum < maxNum || str * 2 + abcnum == maxNum) {

                    texts = Math.ceil((maxNum - (str * 2 + abcnum)) / 2);
                    $("#info").html("您还可以输入的字数<span>" + texts + "</span>").children().css({ "color": "blue" });
                } else if (str * 2 + abcnum > maxNum) {

                    texts = Math.ceil(((str * 2 + abcnum) - maxNum) / 2);
                    $("#info").html("您输入的字数超过了<span>" + texts + "</span>").children("span").css({ "color": "red" });
                }
            }

        })

        $(document).ready(function () {
            jQuery.ajaxSetup({ cache: false });
            $("#MakeSMS").click(function () {
                var tc = $("#txbContent").val();
                if (!tc) { alert('请输入短信内容'); return; }
                $.get("makesms.aspx?t=", { tc: tc }, function (data) {
                    $("#Dspsms").html(data);
                });
            });
            $("#btnGetGroupListName").click(function () {
                var gp = encodeURIComponent($("#ddlpcg").val());

                $.get("makesms.aspx?t=", { gp: gp }, function (data) {

                    $("#pcglistname").html(data);
                });
            });
            $("#btnpselfselect").click(function () {
                var src = 'Customerselecter.aspx?t' + Math.floor(Math.random()) + 1;
                var width = "800px";
                var height = "600px";
                var showScroll = "yes";
                var returnValue = window.showModalDialog(src, "", "location:No;status:No;help:No;dialogWidth:" + width + ";dialogHeight:" + height + ";scroll:" + showScroll + ";");
                var names = StringToArray(returnValue, "元")[1];
                var ids = StringToArray(returnValue, "元")[0];

                $("#pselfselect").html(names);
                $("#pCustomerIDs").val(ids);
            });
        });


        function change(gid) {

            if (gid == "group") {
                $("#group").show(); $("#self").hide(); $("#diy").hide();
                $("#smstmp").show(); //短信模板
                $("#MakeSMS").show(); //查看短信示例按钮
                $("#dspsms").show(); //显示短信样例
            }
            if (gid == "self") {
                $("#group").hide(); $("#self").show(); $("#diy").hide();
                $("#smstmp").show(); //短信模板
                $("#MakeSMS").show(); //查看短信示例按钮
                $("#dspsms").show(); //显示短信样例
            }
            if (gid == "diy") {
                $("#group").hide(); $("#self").hide(); $("#diy").show();
                $("#smstmp").hide(); //短信模板
                $("#MakeSMS").hide(); //查看短信示例按钮
                $("#dspsms").hide(); //显示短信样例

            }
        }


        function SetSms(tid) {
            var text = $("#" + tid + " +span ").text();
            $("#txbContent").html(text);
        }

      
    </script>
</head>
<body style="overflow-x: hidden">
    <form id="form1" runat="server">
    <div>
        <table width="100%" class="tableBorder" border='1' cellspacing="0" style="border-collapse: collapse;"
            bgcolor="#ffffff" bordercolor="#cccccc">
            <tr align="center" valign="middle">
                <th height="22" colspan="3">
                    发 送 短 信
                </th>
            </tr>
            <tr>
                <td width="100px">
                </td>
                <td>
                    <input type="radio" onclick="change('group')" value="group" name="ChkType" checked="checked" />按客户级别群发
                    <input type="radio" onclick="change('self')" value="self" name="ChkType" />从客户列表选择
                    <input type="radio" onclick="change('diy')" value="diy" name="ChkType" />按手机号码
                </td>
            </tr>
            <tr id="group">
                <td width="100px">
                    按客户级别群发
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="ddlpcg">
                    </asp:DropDownList>
                    <input type="button" class="btn" id="btnGetGroupListName" value="获取所选分组名单" />
                    <div id="pcglistname">
                    </div>
                </td>
            </tr>
            <tr id="self" style="display: none;">
                <td width="100px">
                    按自选客户发送
                </td>
                <td>
                    <input type="button" class="btn" id="btnpselfselect" value="点此选取客户" />
                    <input type="text" id="pCustomerIDs" name="pCustomerIDs" value="" style="display: none" />
                    <div id="pselfselect">
                    </div>
                </td>
            </tr>
            <tr id="diy" style="display: none;">
                <td width="100px">
                    接收人手机号
                </td>
                <td>
                    <asp:TextBox runat="server" ID="txbTargets" Width="300px" Height="100px" TextMode="MultiLine"></asp:TextBox>多个手机号请用英文逗号分开
                </td>
            </tr>
            <tr id="smstmp">
                <td width="100px">
                    短信模板
                </td>
                <td>
                    <asp:Literal runat="server" ID="litsms"></asp:Literal>
                </td>
            </tr>
            <tr>
                <td>
                    短信内容
                </td>
                <td>
                    <span id="info">请在下面输入您的文字：</span><br>
                    <asp:TextBox runat="server" ID="txbContent" Width="300px" Height="200px" TextMode="MultiLine"></asp:TextBox>
                    <br>
                    <input type="button" id="MakeSMS" name="MakeSMS" class="btn" value="查看短信样例" />
                    <div id="Dspsms">
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <asp:Button runat="server" ID="btnOk" Text="确定发送" OnClick="btnOk_Click" CssClass="btn" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
